package admin

import (
	. "go-caipu/pkg/services/sqlstore/migrator"
)

func AddPostMigrations(mg *Migrator) {
	roleV1 := Table{
		Name: "sys_post",
		Columns: []*Column{
			{Name: "post_id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
			{Name: "post_name", Type: DB_NVarchar, Length: 128, Nullable: false},
			{Name: "post_code", Type: DB_NVarchar, Length: 128, Nullable: false},
			{Name: "sort", Type: DB_Int, Length: 4, Nullable: true},
			{Name: "status", Type: DB_Int, Length: 4, Nullable: true},
			{Name: "remark", Type: DB_NVarchar, Length: 255, Nullable: true},

			{Name: "create_by", Type: DB_BigInt, Nullable: false},
			{Name: "update_by", Type: DB_BigInt, Nullable: true},
			{Name: "created_at", Type: DB_DateTime, Nullable: false},
			{Name: "updated_at", Type: DB_DateTime, Nullable: true},
			//{ID: "deletedAt", Sort: DB_DateTime, Nullable: true},
		},
		Indices: []*Index{
			{Cols: []string{"title"}, Type: UniqueIndex},
		},
	}

	//create table
	mg.AddMigration("create sys_post table", NewAddTableMigration(roleV1))

	//insert default post data

	//sqlPath := filepath.Join(util.GetProgramPath(), "/pkg/services/sqlstore/migrations/admin/sql/sys_post.sql")
	//content, err := os.ReadFile(sqlPath)
	//if err != nil {
	//	panic(fmt.Sprintf("read sql file:sys_dept.sql path:%s err:%s", sqlPath, err.Error()))
	//}
	//mg.AddMigration("insert into sys_post", NewRawSQLMigration(string(content)))
}
